#include <Python.h>
#include <kuai/misc/xyz.hpp>
#include <kuai/sim/energy.hpp>
#include <kuai/sim/control.hpp>
#include <kuai/sim/md.hpp>

#include "kuaisuan.hpp"


#ifndef _KUAISUAN_CONTROL_HPP_
#define _KUAISUAN_CONTROL_HPP_

namespace kuai { namespace suan {

	class ControlProxy
	{
	public:
		virtual ~ControlProxy()
		{ }

	public:
		virtual bool prepare(PyObject* self, PyObject* model, EnergySet& efunc) = 0;	
		std::auto_ptr<SimulationControl> func;
	};

	class MolecularDynamicControlProxy
		: public ControlProxy
	{
	public:
		bool prepare(PyObject* self, PyObject* model, EnergySet& efunc) {
			VelocityVerletControl* p = new VelocityVerletControl;
			func = std::auto_ptr<SimulationControl>(p);
			return prepare(self, model, efunc, *p);
		};

		static bool prepare(PyObject* self, PyObject* model, EnergySet& efunc, MolecularDynamicControl& result);
	};

	class PythonControl
		: public SimulationControl
	{
	public:
		PythonControl(PyObject* self0, PyObject* model0, size_t period0);
		virtual void act(SimulationEnvironment& env, EnergySet& eset, size_t istep);
		virtual void start(SimulationEnvironment& env, EnergySet& eset);
		virtual void finish(SimulationEnvironment& env, EnergySet& eset, size_t nstep);
		virtual void finalize(SimulationEnvironment& env, EnergySet& eset);

	private:
		PyObject* self;
		PyObject* model;
	};




} }


#endif
